#ifndef CSERVER_SESSION_UPSTREAM_H
#define CSERVER_SESSION_UPSTREAM_H
#include <boost/asio/io_service.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <boost/asio/spawn.hpp>
#include <boost/asio/steady_timer.hpp>
#include <list>
#include <vector>

namespace csrv{
	class Context;
	class LORAUpstream{
		Context& context;
		public:
		explicit LORAUpstream(Context& ctx);
		void start();

		void append(std::vector<char>&& data);
		private:
		std::list<std::vector<char>> mData;
		boost::asio::steady_timer hb_deadline;

		void sleep_for_(int sec, boost::asio::yield_context yield);
		void run_(boost::asio::yield_context yield);
		void run_send_(boost::asio::yield_context yield, std::shared_ptr<boost::asio::ip::tcp::socket> socket);
		void run_receive_(boost::asio::yield_context yield);

	};
	using LORAUpstreamPtr = std::shared_ptr<LORAUpstream>;


}
#endif // end CSERVER_SESSION_UPSTREAM_H

